﻿function loadName() {
    $('#uprovince').combobox({
        data: provinceInfo,
        valueField: 'name',
        textField: 'name',
        editable: false,
        onChange: function (newValue, oldValue) {
            provinceName = newValue;
            for (var provinceIndex in provinceInfo) {
                if (provinceInfo[provinceIndex]["name"] == newValue) {
                    arrCity = provinceInfo[provinceIndex]["sub"];
                    $('#ucity').combobox({
                        data: arrCity,
                        valueField: 'name',
                        textField: 'name',
                        editable: false,
                        onChange: function (newValue, oldValue) {
                            cityName = newValue;
                            for (var provinceIndex in provinceInfo) {
                                if (provinceInfo[provinceIndex]["name"] == provinceName) {
                                    arrCity = provinceInfo[provinceIndex]["sub"];
                                    for (var cityIndex in arrCity) {
                                        if (arrCity[cityIndex]["name"] == cityName) {
                                            arrArea = arrCity[cityIndex]["sub"];
                                            $('#ucounty').combobox({
                                                data: arrArea,
                                                valueField: 'name',
                                                textField: 'name',
                                                editable: false
                                            });
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    });
                    break;
                }
            }
        }
    }
    );
}
function loadNameEdit() {
    $('#uprovince').combobox({
        data: provinceInfo,
        valueField: 'name',
        textField: 'name',
        editable: true,
        //width:'100',
        onChange: function (newValue, oldValue) {
            provinceName = newValue;
            for (var provinceIndex in provinceInfo) {
                if (provinceInfo[provinceIndex]["name"] == newValue) {
                    arrCity = provinceInfo[provinceIndex]["sub"];
                    $('#ucity').combobox({
                        data: arrCity,
                        valueField: 'name',
                        textField: 'name',
                        editable: true,
                        //width: '100',
                        onChange: function (newValue, oldValue) {
                            cityName = newValue;
                            for (var provinceIndex in provinceInfo) {
                                if (provinceInfo[provinceIndex]["name"] == provinceName) {
                                    arrCity = provinceInfo[provinceIndex]["sub"];
                                    for (var cityIndex in arrCity) {
                                        if (arrCity[cityIndex]["name"] == cityName) {
                                            arrArea = arrCity[cityIndex]["sub"];
                                            $('#ucounty').combobox({
                                                data: arrArea,
                                                valueField: 'name',
                                                textField: 'name',
                                                editable: true
                                                //width: '100'
                                            });
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    });
                    break;
                }
            }
        }
    }
    );
}
function loadNameShip() {
    $('#fprovince').combobox({
        data: provinceInfo,
        valueField: 'name',
        textField: 'name',
        editable: false,
        onChange: function (newValue, oldValue) {
            provinceName = newValue;
            for (var provinceIndex in provinceInfo) {
                if (provinceInfo[provinceIndex]["name"] == newValue) {
                    arrCity = provinceInfo[provinceIndex]["sub"];
                    $('#fcity').combobox({
                        data: arrCity,
                        valueField: 'name',
                        textField: 'name',
                        editable: false,
                        onChange: function (newValue, oldValue) {
                            cityName = newValue;
                            for (var provinceIndex in provinceInfo) {
                                if (provinceInfo[provinceIndex]["name"] == provinceName) {
                                    arrCity = provinceInfo[provinceIndex]["sub"];
                                    for (var cityIndex in arrCity) {
                                        if (arrCity[cityIndex]["name"] == cityName) {
                                            arrArea = arrCity[cityIndex]["sub"];
                                            $('#fcounty').combobox({
                                                data: arrArea,
                                                valueField: 'name',
                                                textField: 'name',
                                                editable: false
                                            });
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    });
                    break;
                }
            }
        }
    }
    );
}
function loadNameEdits() {
    $('#uprovinces').combobox({
        data: provinceInfo,
        valueField: 'name',
        textField: 'name',
        editable: true,
        //width: '100',
        onChange: function (newValue, oldValue) {
            provinceName = newValue;
            for (var provinceIndex in provinceInfo) {
                if (provinceInfo[provinceIndex]["name"] == newValue) {
                    arrCity = provinceInfo[provinceIndex]["sub"];
                    $('#ucitys').combobox({
                        data: arrCity,
                        valueField: 'name',
                        textField: 'name',
                        editable: true,
                        //width: '100',
                        onChange: function (newValue, oldValue) {
                            cityName = newValue;
                            for (var provinceIndex in provinceInfo) {
                                if (provinceInfo[provinceIndex]["name"] == provinceName) {
                                    arrCity = provinceInfo[provinceIndex]["sub"];
                                    for (var cityIndex in arrCity) {
                                        if (arrCity[cityIndex]["name"] == cityName) {
                                            arrArea = arrCity[cityIndex]["sub"];
                                            $('#ucountys').combobox({
                                                data: arrArea,
                                                valueField: 'name',
                                                textField: 'name',
                                                editable: true
                                                //width: '100'
                                            });
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    });
                    break;
                }
            }
        }
    }
    );
}
       // 获取省份(直辖市)信息
       function GetProvince() {
           var provSelector = $("#provinceSelector");
           provSelector.empty();
           provSelector.append("<option value=''>--请选择--</option>");
           var arrProvince = provinceInfo;
           for (var provinceIndex in arrProvince) {
               provSelector.append("<option value='" + arrProvince[provinceIndex]["name"] + "'>" + arrProvince[provinceIndex]["name"] + "</option>")
           }
       }

       // 获取指定省份(直辖市)的城市(辖区或县)信息
       function GetCity(provinceName) {
           var citySelector = $("#citySelector");
           var arrCity;
           for (var provinceIndex in provinceInfo) {
               if (provinceInfo[provinceIndex]["name"] == provinceName) {
                   arrCity = provinceInfo[provinceIndex]["sub"];
                   break;
               }
           }
           citySelector.empty();
           citySelector.append("<option value=''>--请选择--</option>")
           for (var cityIndex in arrCity) {
               citySelector.append("<option value='" + arrCity[cityIndex]["name"] + "'>" + arrCity[cityIndex]["name"] + "</option>")
           }
       }

       // 获取指定城市(辖区或县)的地区信息
       function GetArea(provinceName, cityName) {
           var areaSelector = $("#areaSelector");
           var arrCity, arrArea;
           for (var provinceIndex in provinceInfo) {
               if (provinceInfo[provinceIndex]["name"] == provinceName) {
                   arrCity = provinceInfo[provinceIndex]["sub"];
                   for (var cityIndex in arrCity) {
                       if (arrCity[cityIndex]["name"] == cityName) {
                           arrArea = arrCity[cityIndex]["sub"];
                           break;
                       }
                   }
               }
           }
           areaSelector.empty();
           areaSelector.append("<option value=''>--请选择--</option>")
           for (var areaIndex in arrArea) {
               areaSelector.append("<option value='" + arrArea[areaIndex]["name"] + "'>" + arrArea[areaIndex]["name"] + "</option>")
           }
       }
   